package com.yu.mall.configuration;

import com.yu.mall.util.WechatPayUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "wx")
@Data
public class WxConfig {

    private String appid;

    private String secret;

    private String loginUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";

    private String tokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";

    private String userInfoUrl = "https://api.weixin.qq.com/cgi-bin/user/info";

    private String payNotifyUrl;

    private String cert;

    @Bean
    public int initStatic() {
        WechatPayUtil.setNotifyUrl(payNotifyUrl);
        WechatPayUtil.setProjectdPath(cert);
        WechatPayUtil.init();
        return 0;
    }

}
